<?php

namespace app\user\controller;

use app\common\respond\HttpApi;
use app\user\logic\VaccinesRecordLogic;

class VaccinesRecordController
{
    /**
     * @Description 列表
     * @author: zj
     * @param HttpApi $respond
     * @time 2024/03/26 16:42:48
     * @return \think\response\Json
     */
    public function list(HttpApi $respond)
    {
        $param = [
            'page' => (int)request()->get('page') ?: 1,
            'page_size' => (int)request()->get('page_size') ?: 10,
            'pig_id' => request()->get('pig_id'),
            'item_name' => request()->get('item_name'),
            'record_time_start' => request()->get('record_time_start'),
            'record_time_end' => request()->get('record_time_end')
        ];
        $rule = [
            'page' => 'require|integer|>:0',
            'page_size' => 'require|integer|>:0',
            'pig_id' => 'integer|>:0',
            'item_name' => 'max:255',
            'record_time_start' => 'dateFormat:Y-m-d H:i:s',
            'record_time_end' => 'dateFormat:Y-m-d H:i:s'
        ];
        validate($rule)->check($param);

        $logic = new VaccinesRecordLogic();
        $data = $logic->getList($param);

        return $respond->success($data);
    }

}